<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link type="text/css" rel="stylesheet" href="../css/main.css"/>
<link rel="stylesheet" type="text/css" href="../css/kandytabs.css" />
<style type="text/css">
.item-select-list{
	width:100px;

}
</style>
</head>
<body>

<form action="?act=save" method="post"  id="actForm"  name="actForm">

<dl id="act_basic_info">
	<dt>活动基本信息</dt>
	<dd>
		<table class="tb_form">
		
			<tr><td class="td_title">游戏平台</td>
				<td class="td_input" colspan="2">
				<select name="platform_id[]">
				<{foreach from=$platforms key=key item=value}>   
					<option value="<{$value.id}>"><{$value.name}></option>
				<{/foreach}>
				</select>	
				</td>
			</tr>
			
			<{if $act == 'modify'}>
			<tr>
				<td class="td_title">服务器列表</td>
				<td class="td_input" colspan="1">
				<{foreach from=$server_list key=key item=value}>   
					<input name="server_id[]" type="checkbox" value="<{$value.server_id}>"  
							<{foreach from=$server_list_one key=key item=val}>
									<{if $val.server_id == $value.server_id}>checked<{/if}>
							<{/foreach}>
					/>
					<label><{$value.server_name}></label>
				<{/foreach}>	
				</td>
			</tr>
			
			<{else if}>
			<tr>
				<td class="td_title">服务器列表</td>
				<td class="td_input" colspan="1">
				<{foreach from=$server_list key=key item=value}>   
					<input name="server_id[]" type="checkbox" value="<{$value.server_id}>" />
					<label><{$value.server_name}></label>
				<{/foreach}>	
				</td>
			</tr>
			<{/if}>
			
			
			
			<tr>
				<td class="td_title">活动名称</td>
				<td class="td_input"><input type="text" size="20" name="actName" value="<{if $actName !=null}><{$actName}><{/if}>"/></td>
			</tr>
			<tr>
				<td class="td_title">活动开始时间</td>
				<td class="td_input"><input value="<{if $start_date !=null}><{$start_date}><{/if}>" name="begin_time" type="text" id="begin_time" size="50" class="Wdatetime" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/></td>
			</tr>
			<tr>
				<td class="td_title">活动领奖时间</td>
				<td class="td_input"  colspan="2"><input value="<{if $award_date !=null}><{$award_date}><{/if}>" name="award_time" type="text" id="award_time" size="50" class="Wdatetime" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/></td>
			</tr>
			<tr>
				<td class="td_title">活动到期时间</td>
				<td class="td_input"><input value="<{if $finish_date !=null}><{$finish_date}><{/if}>" name="end_time" type="text" id="end_time" size="50" class="Wdatetime" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/></td>
			</tr>
			<tr>
				<td class="td_title">活动内容</td>
				<td class="td_input"  colspan="2"><textarea cols="50"  rows="10" name="actContent"><{if $act_content !=null}><{$act_content}><{/if}></textarea></td>
			</tr>
				<tr><td colspan="5">
						<{if $act == 'modify'}><input type="hidden" name="act_id" value="<{$act_id}>"><{/if}>
						<input type="submit" value="保存"  id="submit"/>
						</td></tr>
			</table>
	</dd>
	
	<dt>活动规则设置</dt>
	<dd>
		<table class="tb_form">
					<tr class="tb_title"><td>活动类型</td><td>活动规则</td></tr>
					
					<tr>
						<td class="td_input td_inner" width="30%">
							<label>执行脚本(lua函数名)</label>
							<input name="activitys_type[1]"  type="checkbox" class="check-btn" value="1"  <{if $luaName !=null}>checked<{/if}>/>
						</td>
						<td class="td_input " colspan="3" >
							<input type="text" size="30"  name="luaName" id="luaName"  class="act-info-input"   value="<{if $luaName !=null}><{$luaName}><{/if}>" />
						</td>
					</tr>
					
					<tr>
						<td class="td_input td_inner">
							<label>增加掉落物品</label>
							<input name="activitys_type[2]"   type="checkbox" class="check-btn"  value="2" <{if $items_edit !=null}>checked<{/if}> />
						</td>
						<td class="td_input "  colspan="3">
						
						<{if $items_edit != null}>
						
							<ul class="drop-item-ul" >
								<button class="add-item-btn act-info-input" type="button" >增加</button>
							<{foreach from=$items_edit key=k item=val}>
									<li id="drop_item_li_1">
									<select  name="copys_selected[]"    class="copys_selected act-info-input"  >
										<optgroup label="普通地图">
													<option  value="0"  <{if $val.copyid==0}>selected<{/if}>>普通地图</option>
										</optgroup>
										<optgroup label="副本地图">
													<{foreach from=$copys key=key item=value}>
													<option  value="<{$value.id}>" id="<{$value.id}>" <{if $value.id == $val.copyid}>selected<{/if}>><{$value.copy_name}></option>
													<{/foreach}>
										</optgroup>
									</select>
									
									<select  name="maps_selected[]"   class="maps_selected act-info-input" >
										<option value="0" <{if $val.mapid==0}>selected<{/if}>>尚未指定地图</option>
										<{foreach from=$maps_edit[$k] key=key item=value}>
										<option value="<{$value.map_id}>" id="<{$value.map_id}>" <{if $value.map_id == $val.mapid}>selected<{/if}>><{$value.name}></option>
										<{/foreach}>
									</select>
									
									<select  name="monsters_selected[]"  class="monsters_selected act-info-input" >
										<option value="0">尚未指定怪物</option>
										<{foreach from=$monsters_edit[$k] key=key item=value}>
										<option  value="<{$value.id}>" id="<{$value.id}>" <{if $value.id == $val.mapmonsterid}>selected<{/if}>><{$value.name}></option>
										<{/foreach}>
									</select>
									
									<select  name="items_selected[]"   class="items_selected act-info-input" >
										<{foreach from=$itemlibs key=key item=value}>
										<option  value="<{$value.id}>" id="<{$value.id}>" <{if $value.id == $val.item}>selected<{/if}>><{$value.lib_name}></option>
										<{/foreach}>
									</select>
							 		<input type="text" name="items_min_num[]" value="<{$val.item_min_num}>"   class="act-info-input" size="3"/> 
							 		~ 
							 		<input type="text"  class="act-info-input" name="items_max_num[]" value="<{$val.item_max_num}>" size="3"/>
							 		<button class="del-item-btn act-info-input" type="button" >删除</button>
									</li>
						<{/foreach}>
							</ul>
							
						<{else }>
						
							<ul class="drop-item-ul">
									<button class="add-item-btn act-info-input" type="button" >增加</button>
									<li id="drop_item_li_1">
									<select  name="copys_selected[]"    class="copys_selected act-info-input" >
										<option>尚未指定场景</option>
										<optgroup label="普通地图">
													<option  value="0" >普通地图</option>
										</optgroup>
										<optgroup label="副本地图">
													<{foreach from=$copys key=key item=value}>
													<option  value="<{$value.id}>" id="<{$value.id}>"><{$value.copy_name}></option>
													<{/foreach}>
										</optgroup>
									</select>
									<select name="maps_selected[]"   class="maps_selected act-info-input" ><option value="0">尚未指定地图</option></select>
									<select name="monsters_selected[]"  class="monsters_selected act-info-input" ><option value="0">尚未指定怪物</option></select>
									<select name="items_selected[]"   class="items_selected act-info-input" >
										<option value="0">尚未指定掉落物品</option>
										<{foreach from=$itemlibs key=key item=value}>
										<option  value="<{$value.id}>" id="<{$value.id}>"><{$value.lib_name}></option>
										<{/foreach}>
									</select>
							 		<input type="text" name="items_min_num[]" value=""   class="act-info-input" size="3"/> ~ <input type="text"  class="act-info-input" name="items_max_num[]" value="" size="3"/>
							 		<button class="del-item-btn act-info-input" type="button" >删除</button>
									</li>
							</ul>
						<{/if}>
							
						</td>
					</tr>
					
					<tr>
						<td class="td_input td_inner">
							<label>删除商店商品</label>
							<input name="activitys_type[3]" type="checkbox"  class="check-btn" value="3"  <{if $del_goods !=null}>checked<{/if}>/>
						</td>
						
						<{if $del_goods != null}>
						<td class="td_input "  colspan="3">
						<ul class="del-goods-ul">
						<button type="button"  class="add-goods-btn act-info-input">增加</button>
						<{foreach from=$del_goods key=k item=val}>
							<li id="del_goods_set[0]">
							<select name="del_shops_selected[]"  class="del_shop_selected act-info-input">
								<option>尚未指定商店</option>
								<{foreach from=$shops key=key item=value}>
								<option value="<{$value.id}>" id="<{$value.id}>" <{if $value.id == $val.shopid}>selected<{/if}>><{$value.name}></option>
								<{/foreach}>
							</select>
							
							<select  name="del_goods_selected[]" class="del_goods_selected act-info-input">
							<option value="0">尚未指定商品</option>
							<{foreach from=$del_goods_edit[$k] key=key item=value}>
							<option value="<{$value.id}>" id="<{$value.id}>" <{if $value.id == $val.goodsid}>selected<{/if}>><{$value.name}></option>
							<{/foreach}>
							</select>
							
							<input type="text" size="6" value="<{$val.index}>" id="del_goods_index"  class="act-info-input" name="del_goods_index[]"/>
							<button type="button"  class="del-goods-btn act-info-input">删除</button>
							</li>
						<{/foreach}>
						</ul>
						</td>
						<{else}>
						
							<td class="td_input "  colspan="3">
								<ul class="del-goods-ul">
									<button type="button"  class="add-goods-btn act-info-input">增加</button>
									<li id="del_goods_set[0]">
									<select name="del_shops_selected[]"  class="del_shop_selected act-info-input">
										<option>尚未指定商店</option>
										<{foreach from=$shops key=key item=value}>
										<option value="<{$value.id}>" id="<{$value.id}>"><{$value.name}></option>
										<{/foreach}>
									</select>
									<select  name="del_goods_selected[]" class="del_goods_selected act-info-input"><option value="0">尚未指定商品</option></select>
									<input type="text" size="6" value="" id="del_goods_index"  class="act-info-input" name="del_goods_index[]"/>
									<button type="button"  class="del-goods-btn act-info-input">删除</button>
									</li>
								</ul>
							</td>
						<{/if}>
						
					</tr>
					
					<tr>
						<td class="td_input td_inner">
							<label for="activitys_type[4]">增加商店商品</label>
							<input id="activitys_type[4]" name="activitys_type[4]" type="checkbox"  class="check-btn" value="4" <{if $add_goods !=null}>checked<{/if}> />
						</td>
						<td class="td_input "  colspan="3">
						<{if $add_goods != null}>
							<ul class="add-goods-ul">
								<button type="button"  class="add-goods-addbtn act-info-input">增加</button>
								<{foreach from=$add_goods key=k item=val}>
								<li id="add_goods_li_1">
								
								<select name="add_shops_selected[]"  class="add_shop_selected act-info-input">
									<option value="0">尚未指定商店</option>
									<{foreach from=$shops key=key item=value}>
									<option  value="<{$value.id}>" id="<{$value.id}>" <{if $value.id == $val.shopid}>selected<{/if}>><{$value.name}></option>
									<{/foreach}>
								</select>
								
								<select  name="add_goods_selected[]" class="add_goods_selected act-info-input">
									<{foreach from=$add_goods_edit[$k] key=key item=value}>
									<option value="<{$value.id}>" id="<{$value.id}>" <{if $value.id == $val.goodsid}>selected<{/if}>><{$value.name}></option>
									<{/foreach}>
								</select>
								
								<input type="text" size="6" value="<{$val.index}>" id="add_goods_index"  class="act-info-input" name="add_goods_index[]"/>
								<button type="button"  class="add-goods-delbtn act-info-input">删除</button>
								</li>
								<{/foreach}>
							</ul>
						<{else}>
							<ul class="add-goods-ul">
								<button type="button"  class="add-goods-addbtn act-info-input">增加</button>
								<li id="add_goods_li_1">
								
								<select name="add_shops_selected[]"  class="add_shop_selected act-info-input">
									<option>尚未指定商店</option>
									<{foreach from=$shops key=key item=value}>
									<option  value="<{$value.id}>" id="<{$value.id}>"><{$value.name}></option>
									<{/foreach}>
								</select>
								
								<select  name="add_goods_selected[]" class="add_goods_selected act-info-input"><option value="0">尚未指定商品</option></select>
								<input type="text" size="6" value="" id="add_goods_index"  class="act-info-input" name="add_goods_index[]"/>
								<button type="button"  class="add-goods-delbtn act-info-input">删除</button>
								</li>
							</ul>
						<{/if}>
						</td>
					</tr>
					
					<tr>
						<td class="td_input td_inner">
							<label>动态广播信息</label>
							<input name="activitys_type[5]" type="checkbox"  class="check-btn" value="5" <{if $interval !=null}>checked<{/if}>/>
						</td>
						<td class="td_input "  colspan="3">
							<input type="text" size="10" value="<{$interval}>"  class="act-info-input" name="interval"/>
							<input type="text" size="30" value="<{$info}>" class="act-info-input"  name="info"/>
						</td>
					</tr>
					
					<tr>
						<td class="td_input td_inner">
							<label>右上角显示图标信息(图标编号)</label>
							<input name="activitys_type[6]" type="checkbox" class="check-btn"  value="6" <{if $iconId !=null}>checked<{/if}>/>
						</td>
						<td class="td_input "  colspan="3">
							<input type="text" size="10" value="1025"  class="act-info-input" name="iconId" />
						</td>
					</tr>
				</table>
			
	</dd>
	
	<dt>活动奖励设置</dt>
	<dd>
	
			<button class="add-gift-package-btn" type="button">增加礼包</button>
			
			<div class="gift-package-div">
			
			<{if $gifts != null}>
			<{foreach from=$gifts key=k item=val}>
			<table class="tb_form gift-package-table">
				<tr class="parent" id="row_01"><td class="tb_title" colspan="2">礼包<span class="gift-package-id"><{$k}></span>设置<img class="close-package" src="../images/close.jpg"/></td></tr>
				
				<tr class="child_row_01">
					<td class="td_input td_inner">活动奖励物品<input type="checkbox"  value="1"   class="check-btn" <{if $val.item !=null}>checked<{/if}> /></td>
					<td   class="td_input">
						<button type="button" class="add-giftitem-btn act-info-input" >增加</button>
						<ul class="gift_item_ul" id="gift_item_ul_<{$k}>" >
							<{foreach from=$val.item key=key item=value}>
							<li class="gift_item_li">
								<input type="text" size="30"  name="gifts[<{$k}>][item][<{$key}>][name]"  class="act-info-input giftItem-name "  value="<{$value.name}>"/>
								<input type="text" size="10"  name="gifts[<{$k}>][item][<{$key}>][num]" class="act-info-input giftItem-num "    value="<{$value.num}>"/>
								<input class="giftItem-property-bang act-info-input"  type="radio" value="1"  name="gifts[<{$k}>][item][<{$key}>][property]" <{if $value.property==1}>checked<{/if}>/><label>绑定</label>
								<input class="giftItem-property-unbang act-info-input"  type="radio" value="0"  name="gifts[<{$k}>][item][<{$key}>][property]" <{if $value.property==0}>checked<{/if}>/><label>非绑定</label>
								<button type="button" class="act-info-input del-giftitem-btn">删除</button>
							</li>
							<{/foreach}>
						</ul>
					</td>
				</tr>
			
				<tr class="tb_subtitle  child_row_01"><td>奖励类型</td><td>奖励规则</td></tr>
				
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>充值数量</label>
					<input type="checkbox"  value="1"   class="check-btn" name="gift_type[1][]" <{if $val.charge_num !=null}>checked<{/if}>/>
					</td>
					<td  colspan="3" class="td_input"><input type="text"   class="charge-num act-info-input" name="gifts[<{$k}>][charge_num]" value="<{$val.charge_num}>"/></td></tr>
					
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>消费数量</label>
					<input type="checkbox" value="1"   class="check-btn" name="gift_type[2][]" <{if $val.consume_num !=null}>checked<{/if}> />
					</td>
					<td colspan="3" class="td_input"><input type="text"   class="consume-num act-info-input" name="gifts[<{$k}>][consume_num]"  value="<{$val.consume_num}>"/></td></tr>
					
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>一次性充值</label>
					<input type="checkbox" value="1"  class="check-btn"  name="gift_type[3][]" <{if $val.charge_one_num !=null}>checked<{/if}>/>
					</td>
					<td colspan="3" class="td_input"><input type="text"   class="charge-one-num act-info-input" name="gifts[<{$k}>][charge_one_num]"  value="<{$val.charge_one_num}>"/></td></tr>
					
				<tr class="child_row_01"><td class="td_input td_inner">
				<label>需要礼包卡号(value是tb_system_package字段package_type的值)</label>
				<input type="checkbox" value="1"  class="check-btn" name="gift_type[4][]" <{if $val.package_type !=null}>checked<{/if}>/>
				</td>
				<td colspan="3" class="td_input">
					<select name="gifts[<{$k}>][package_type]" class="package-type act-info-input">
					<option value="0">尚未指定礼包卡类型</option>
					<{foreach from=$actTypes key=key item=value}>
						<option value="<{$value.id}>" id="<{$value.id}>" <{if $val.package_type==$value.id}>selected<{/if}>><{$value.act_type}></option>
					<{/foreach}>
					</select>
					</td></tr>	
					
				<tr class="child_row_01"><td class="td_input td_inner">
				<label>在线时间</label>
				<input type="checkbox" value="1"  class="check-btn"  name="gift_type[5][]" <{if $val.online_time!=null}>checked<{/if}>/>
				</td>
				<td colspan="3" class="td_input">
				<input type="text"  class="online-time act-info-input"  name="gifts[<{$k}>][online_time]"  value="<{$val.online_time}>"/>小时</td></tr>
				
				<tr class="child_row_01"><td class="td_input td_inner">
				<label>VIP等级</label>
				<input type="checkbox" value="1"  class="check-btn"  name="gift_type[6][]" <{if $val.vip_level!=null}>checked<{/if}>/>
				</td>
				<td colspan="3" class="td_input">
				<input type="text"  class="vip-level act-info-input"  name="gifts[<{$k}>][vip_level]" value="<{$val.vip_level}>"/></td></tr>
				
				<tr class="child_row_01"><td class="td_input td_inner">
				<label>连续登陆天数</label>
				<input type="checkbox" value="1"  class="check-btn"  name="gift_type[7][]" <{if $val.continues_login!=null}>checked<{/if}>/>
				</td>
				<td colspan="3" class="td_input">
				<input type="text"   class="continues-login act-info-input" name="gifts[<{$k}>][continues_login]" value="<{$val.continues_login}>"/>天</td></tr>
				
				<tr class="child_row_01"><td class="td_input td_inner">
				<label>连续未登录天数</label>
				<input type="checkbox" value="1"  class="check-btn"  name="gift_type[8][]" <{if $val.continues_logoff !=null}>checked<{/if}>/>
				</td>
				<td colspan="3" class="td_input">
				<input type="text"   class="continues-logoff act-info-input" name="gifts[<{$k}>][continues_logoff]" value="<{$val.continues_logoff}>"/>天</td></tr>
				
				<tr class="child_row_01"><td class="td_input td_inner">
				<label>收到玫瑰数量</label>
				<input type="checkbox" value="1"   class="check-btn" name="gift_type[9][]" <{if $val.receive_rose !=null}>checked<{/if}>/>
				</td>
				<td colspan="3" class="td_input">
				<input type="text"   class="receive-rose act-info-input" name="gifts[<{$k}>][receive_rose]" value="<{$val.receive_rose}>"/>朵</td></tr>
				
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>达到排行榜名次(rank:min:max,rank是排行榜类型，min,max是名次区间)</label>
					<input type="checkbox" value="1"   class="check-btn" name="gift_type[4097][]" <{if $val.rank_type!=null}>checked<{/if}>/>
					</td>
					<td colspan="3" class="td_input">
						<select name="gifts[<{$k}>][rank_type]" class="rank-type act-info-input">
							<option value="0">尚未指定排行榜</option>
						<{foreach from=$rankTypes key=key item=value}>
							<option value="<{$key}>" <{if $val.rank_type==$key}>selected<{/if}>><{$value}></option>
						<{/foreach}>
						</select>
						<label>排名区间 </label>
						<input type="text" name="gifts[<{$k}>][rank_index_min]" value="<{$val.rank_index_min}>"   class="rank-index-min act-info-input" size="10"/>~
						<input type="text" name="gifts[<{$k}>][rank_index_max]"  value="<{$val.rank_index_max}>"  class="rank-index-max act-info-input" size="10"/>
					</td>
				</tr>
					
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>参与系统功能次数(function:times, function表示功能，times表示次数)</label>
					<input type="checkbox" value="1"   class="check-btn"  class="act-info-input"  name="gift_type[4098][]" <{if $val.system_function!=null}>checked<{/if}>/>
					</td>
					<td colspan="3" class="td_input">
						<select name="gifts[<{$k}>][system_function]" class="system-function act-info-input">
							<option value="0">尚未指定系统功能</option>
						<{foreach from=$sysFunctions  key=key item=value}>
							<option value="<{$value.param_name}>" <{if $val.system_function==$value.param_name}>selected<{/if}>><{$value.param_value}></option>
						<{/foreach}>
						</select>
						<input type="text" name="gifts[<{$k}>][system_times]"  class="system-times act-info-input"  value="<{$val.system_times}>" size="5"/>
					</td></tr>
					
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>职业限制(value表示可以领取的职业)</label>
					<input type="checkbox" value="1"  class="check-btn"  name="" <{if $val.profession_limit_zhanshi!=null || $val.profession_limit_fashi!=null || $val.profession_limit_gongshou!=null}>checked<{/if}>/>
					</td>
					<td colspan="3" class="td_input">
						<input type="checkbox"  class="profession-limit-zhanshi act-info-input" value="4" <{if $val.profession_limit_zhanshi !=null}>checked<{/if}>  class="profession-limit act-info-input" name="gifts[<{$k}>][profession_limit_zhanshi]"/><label>战士</label>
						<input type="checkbox"  class="profession-limit-fashi act-info-input"  value="2"  <{if $val.profession_limit_fashi!=null}>checked<{/if}> class="profession-limit act-info-input" name="gifts[<{$k}>][profession_limit_fashi]"/><label>法师</label>
						<input type="checkbox"  class="profession-limit-gongshou act-info-input"  value="1"  <{if $val.profession_limit_gongshou!=null}>checked<{/if}> class="profession-limit act-info-input" name="gifts[<{$k}>][profession_limit_gongshou]"/><label>弓手</label>
					</td>
				</tr>
						
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>等级限制(min表示最小可领取等级，max表示最大可领取等级)</label>
					<input type="checkbox" value="1"   class="check-btn" name="gift_type[4100][]" <{if $val.level_min_limit !=null}>checked<{/if}>/>
					</td>
					<td colspan="3" class="td_input">
						<input type="text" name="gifts[<{$k}>][level_min_limit]"   class="level-min-limit act-info-input" size="10" value="<{$val.level_min_limit}>"/> - 
						<input type="text" name="gifts[<{$k}>][level_max_limit]"   class="level-max-limit act-info-input" size="10" value="<{$val.level_max_limit}>"/>
					</td></tr>
					
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>帮派等级限制</label>
					<input type="checkbox" value="1"   class="check-btn" name="gift_type[4101][]" <{if $val.bang_level !=null}>checked<{/if}>/>
					</td>
					<td colspan="3" class="td_input">
						<input type="text" name="gifts[<{$k}>][bang_level]"   class="bang-level act-info-input" size="10" value="<{$val.bang_level}>" />
					</td></tr>
					
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>帮派繁荣度限制</label>
					<input type="checkbox" value="1"  class="check-btn"  name="gift_type[4102][]" <{if $val.bang_bloom !=null}>checked<{/if}>/>
					</td>
					<td colspan="3" class="td_input">
					<input type="text"   class="bang-bloom act-info-input" name="gifts[<{$k}>][bang_bloom]" value="<{$val.bang_bloom}>" /></td></tr>
					
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>呼朋唤友次数</label>
					<input type="checkbox" value="1"  class="check-btn"  name="gift_type[4103][]" <{if $val.friend_times !=null}>checked<{/if}>/>
					</td>
					<td colspan="3" class="td_input">
					<input type="text"   class="friend-times act-info-input" name="gifts[<{$k}>][friend_times]" value="<{$val.friend_times}>" /></td></tr>
					
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>性别限制</label>
					<input type="checkbox" value="1"  class="check-btn"   <{if $val.sex_limit !=null}>checked<{/if}>/>
					</td>
					<td colspan="3" class="td_input">
							<input type="radio" class="sex-limit  act-info-input" name="gifts[<{$k}>][sex_limit]"  value="1"  <{if $val.sex_limit ==1}>checked<{/if}>/><label>男</label>
							<input type="radio" class="sex-limit  act-info-input" name="gifts[<{$k}>][sex_limit]"  value="2" <{if $val.sex_limit ==2}>checked<{/if}>/><label>女</label>		
					</td>
				</tr>
					
			</table>
			<{/foreach}>
			<{else}>
			
			<table class="tb_form gift-package-table">
				<tr class="parent" id="row_01"><td class="tb_title" colspan="2">礼包<span class="gift-package-id">1</span>设置<img class="close-package" src="../images/close.jpg"/></td></tr>
				
				<tr class="child_row_01">
					<td class="td_input td_inner">活动奖励物品<input type="checkbox"  value="1"   class="check-btn" name=""/></td>
					<td   class="td_input">
						<button type="button" class="add-giftitem-btn act-info-input" >增加</button>
						<ul class="gift_item_ul" id="gift_item_ul_1" >
							<li class="gift_item_li">
								<input type="text"  name="gifts[1][item][0][name]" size="30" class="act-info-input giftItem-name "  value=""/>
								<input type="text"  name="gifts[1][item][0][num]" size="10" class="act-info-input giftItem-num "    value=""/>
								<input class="giftItem-property-bang act-info-input"  type="radio" value="1"  name="gifts[1][item][0][property]" checked="checked"/><label>绑定</label>
								<input class="giftItem-property-unbang act-info-input"  type="radio" value="0"  name="gifts[1][item][0][property]"/><label>非绑定</label>
								<button type="button" class="act-info-input del-giftitem-btn">删除</button>
							</li>
						</ul>
					</td>
				</tr>
			
				<tr class="tb_subtitle  child_row_01"><td>奖励类型</td><td>奖励规则</td></tr>
				
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>充值数量</label>
					<input type="checkbox"  value="1"   class="check-btn" name="gift_type[1][]"/>
					</td>
					<td  colspan="3" class="td_input"><input type="text"   class="charge-num act-info-input" name="gifts[1][charge_num]"/></td></tr>
					
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>消费数量</label>
					<input type="checkbox" value="1"   class="check-btn" name="gift_type[2]"/>
					</td>
					<td colspan="3" class="td_input"><input type="text"   class="consume-num act-info-input" name="gifts[1][consume_num]"/></td></tr>
					
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>一次性充值</label>
					<input type="checkbox" value="1"  class="check-btn"  name="gift_type[3]"/>
					</td>
					<td colspan="3" class="td_input"><input type="text"   class="charge-one-num act-info-input" name="gifts[1][charge_one_num]"/></td></tr>
					
				<tr class="child_row_01"><td class="td_input td_inner">
				<label>需要礼包卡号(value是tb_system_package字段package_type的值)</label>
				<input type="checkbox" value="1"  class="check-btn" name="gift_type[4]"/>
				</td>
				<td colspan="3" class="td_input">
					<select name="gifts[1][package_type]" class="package-type act-info-input">
					<option value="0">尚未指定礼包卡类型</option>
					<{foreach from=$actTypes key=key item=value}>
						<option value="<{$value.id}>" id="<{$value.id}>"><{$value.act_type}></option>
					<{/foreach}>
					</select>
					</td></tr>	
					
				<tr class="child_row_01"><td class="td_input td_inner">
				<label>在线时间</label>
				<input type="checkbox" value="1"  class="check-btn"  name="gift_type[5][]"/>
				</td>
				<td colspan="3" class="td_input"><input type="text"  class="online-time act-info-input"  name="gifts[1][online_time]"/>小时</td></tr>
				
				<tr class="child_row_01"><td class="td_input td_inner">
				<label>VIP等级</label>
				<input type="checkbox" value="1"  class="check-btn"  name="gift_type[6][]"/>
				</td>
				<td colspan="3" class="td_input"><input type="text"  class="vip-level act-info-input"  name="gifts[1][vip_level]"/></td></tr>
				
				<tr class="child_row_01"><td class="td_input td_inner">
				<label>连续登陆天数</label>
				<input type="checkbox" value="1"  class="check-btn"  name="gift_type[7][]"/>
				</td>
				<td colspan="3" class="td_input"><input type="text"   class="continues-login act-info-input" name="gifts[1][continues_login]"/>天</td></tr>
				
				<tr class="child_row_01"><td class="td_input td_inner">
				<label>连续未登录天数</label>
				<input type="checkbox" value="1"  class="check-btn"  name="gift_type[8][]"/>
				</td>
				<td colspan="3" class="td_input"><input type="text"   class="continues-logoff act-info-input" name="gifts[1][continues_logoff]"/>天</td></tr>
				
				<tr class="child_row_01"><td class="td_input td_inner">
				<label>收到玫瑰数量</label>
				<input type="checkbox" value="1"   class="check-btn" name="gift_type[9][]"/>
				</td>
				<td colspan="3" class="td_input"><input type="text"   class="receive-rose act-info-input" name="gifts[1][receive_rose]"/>朵</td></tr>
				
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>达到排行榜名次(rank:min:max,rank是排行榜类型，min,max是名次区间)</label>
					<input type="checkbox" value="1"   class="check-btn" name="gift_type[4097][]"/>
					</td>
					<td colspan="3" class="td_input">
						<select name="gifts[1][rank_type]" class="rank-type act-info-input">
							<option value="0">尚未指定排行榜</option>
						<{foreach from=$rankTypes key=key item=value}>
							<option value="<{$key}>"><{$value}></option>
						<{/foreach}>
						</select>
						<label>排名区间 </label>
						<input type="text" name="gifts[1][rank_index_min]"   class="rank-index-min act-info-input" size="10"/>~
						<input type="text" name="gifts[1][rank_index_max]"   class="rank-index-max act-info-input" size="10"/>
					</td>
				</tr>
					
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>参与系统功能次数(function:times, function表示功能，times表示次数)</label>
					<input type="checkbox" value="1"   class="check-btn"  class="act-info-input"  name="gift_type[4098][]"/>
					</td>
					<td colspan="3" class="td_input">
						<select name="gifts[1][system_function]" class="system-function act-info-input">
							<option value="0">尚未指定系统功能</option>
						<{foreach from=$sysFunctions  key=key item=value}>
							<option value="<{$value.param_name}>"><{$value.param_value}></option>
						<{/foreach}>
						</select>
						<input type="text" name="gifts[1][system_times]"  class="system-times act-info-input"  size="5"/>
					</td></tr>
					
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>职业限制(value表示可以领取的职业)</label>
					<input type="checkbox" value="1"  class="check-btn"  name="gift_type[4099][]"/>
					</td>
					<td colspan="3" class="td_input">
						<input type="checkbox" class="profession-limit-zhanshi act-info-input" value="4"  class="profession-limit act-info-input" name="gifts[1][profession_limit_zhanshi]"/><label>战士</label>
						<input type="checkbox"  class="profession-limit-fashi act-info-input" value="2"  class="profession-limit act-info-input" name="gifts[1][profession_limit_fashi]"/><label>法师</label>
						<input type="checkbox" class="profession-limit-gongshou act-info-input" value="1"  class="profession-limit act-info-input" name="gifts[1][profession_limit_gongshou]"/><label>弓手</label>
						</td></tr>
						
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>等级限制(min表示最小可领取等级，max表示最大可领取等级)</label>
					<input type="checkbox" value="1"   class="check-btn" name="gift_type[4100][]"/>
					</td>
					<td colspan="3" class="td_input">
						<input type="text" name="gifts[1][level_min_limit]"   class="level-min-limit act-info-input" size="10"/> - 
						<input type="text" name="gifts[1][level_max_limit]"   class="level-max-limit act-info-input" size="10"/>
					</td></tr>
					
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>帮派等级限制</label>
					<input type="checkbox" value="1"   class="check-btn" name="gift_type[4101][]"/>
					</td>
					<td colspan="3" class="td_input">
						<input type="text" name="gifts[1][bang_level]"   class="bang-level act-info-input" size="10"/>
					</td></tr>
					
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>帮派繁荣度限制</label>
					<input type="checkbox" value="1"  class="check-btn"  name="gift_type[4102][]"/>
					</td>
					<td colspan="3" class="td_input">
					<input type="text"   class="bang-bloom act-info-input" name="gifts[1][bang_bloom]"/></td></tr>
					
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>呼朋唤友次数</label>
					<input type="checkbox" value="1"  class="check-btn"  name="gift_type[4103][]"/>
					</td>
					<td colspan="3" class="td_input">
					<input type="text"   class="friend-times act-info-input" name="gifts[1][friend_times]"/></td></tr>
					
				<tr class="child_row_01"><td class="td_input td_inner">
					<label>性别限制</label>
					<input type="checkbox" value="1"  class="check-btn"  name="gift_type[4104][]"/>
					</td>
					<td colspan="3" class="td_input">
							<input type="radio" class="sex-limit  act-info-input"  value="1"  checked="checked" name="gifts[1][sex_limit]"/><label>男</label>
							<input type="radio" class="sex-limit  act-info-input"  value="2"  name="gifts[1][sex_limit]"/><label>女</label>		
					</td>
				</tr>
					
			</table>
			
			<{/if}>
			
			</div>
			</dd>
		</dl>
	</dd>
</dl>

</form>

<script type="text/javascript" src="../js/jquery-1.7.1.js"></script>
<script type="text/javascript" src="../js/jquery.form.js"></script>
<script type="text/javascript" src="../js/kandytabs.pack.js"></script>
<script language="javascript" type="text/javascript" src="../js/datecontrols/WdatePicker.js"></script>
<script charset="utf-8" src="../js/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="../js/kindeditor/lang/zh_CN.js"></script> 
<script type="text/javascript">
$(function(){
  	$("#act_basic_info").KandyTabs();

  	$(".act-info-input").each(function(){
  			var check = $(this).parents().find('.check-btn').attr('checked');
	  	  	if(check==undefined){
				  	$(this).attr("disabled", "disabled");
	  	  	}
  	  	});

	$(".check-btn").click(function(){
			var a = $(this).parent().siblings().find('.act-info-input');
			a.each(function(){
			        if ($(this).attr("disabled") == undefined) {
			            $(this).attr("disabled", "disabled");
			        } else {
			            $(this).removeAttr("disabled");
			        }
					
				});
		}
	);

	//增加掉落物品
	$(".add-item-btn").click(function(){
		  	var li = $(this).parents(".drop-item-ul").children("li");
		  	var length = li.length;
			li.eq(length-1).clone(true).appendTo(".drop-item-ul");
			$(this).parents(".drop-item-ul").children("li").each(function(i){
					$(this).attr("id","drop_item_li_"+(i+1));
				});
		});

	//删除掉落物品
	$(".del-item-btn").click(function(){
		  	var li = $(this).parents(".drop-item-ul").children("li");
		  	var length = li.length;
		  	if(length == 1){
			  	return false;
		  	}
			$(this).parent().remove();
			$(this).parents(".drop-item-ul").children("li").each(function(i){
					$(this).attr("id","drop_item_li_"+(i+1));
				});
		});

	//获取指定场景的地图列表
	$(".copys_selected").change(function(){
			var copyid = $(this).val();
			var list = $(this).siblings(".maps_selected");
			list.empty();
			list.addClass("item-select-list");
			$.getJSON(
				'activity_manage.php?act=map',
				{copyid:copyid},
				function(callback){
					$.each(callback,function(i,msg){
						var option= '<option  value="'+ msg.map_id +'" id="'+ msg.map_id +'">'+ msg.name +'</option>';
						list.append(option);
					});
				} 
			);
		});

	//获取指定地图的怪物列表
	$(".maps_selected").change(function(){
			var monstersid = $(this).val();
			var list = $(this).siblings(".monsters_selected");
			list.empty();
			list.addClass("item-select-list");
			$.getJSON(
					'activity_manage.php?act=mapmonsters',
					{monstersid:monstersid},
					function(callback){
						$.each(callback,function(i,msg){
							var option= '<option onclick="" value="'+ msg.id +'" id="'+ msg.id +'">'+ msg.name +'</option>';
							//alert(option);
							list.append(option);
						});
						var len = callback.length;
						if(len == 1){
							list.trigger("change");
						}
					} 
				);
		});

	//删除商店商品增加
	$(".add-goods-btn").click(function(){
		  	var li = $(this).parents(".del-goods-ul").children("li");
		  	var length = li.length;
			li.eq(length-1).clone(true).appendTo(".del-goods-ul");
			$(this).parents(".del-goods-ul").children("li").each(function(i){
					$(this).attr("id","del_goods_li_"+(i+1));
				});
		});

	//删除商店商品删除
	$(".del-goods-btn").click(function(){
		  	var li = $(this).parents(".del-goods-ul").children("li");
		  	var length = li.length;
		  	if(length == 1){
			  	return false;
		  	}
			$(this).parent().remove();
			$(this).parents(".del-goods-ul").children("li").each(function(i){
					$(this).attr("id","del_goods_li_"+(i+1));
				});
		});

	//获取删除商店的商品列表
	$(".del_shop_selected").change(function(){
			var shopid=$(this).val();
			var li = $(this).siblings(".del_goods_selected");
			li.empty();
			$.getJSON(
					'activity_manage.php?act=goodslist',
					{shopid:shopid},
					function(callback){
						$.each(callback,function(i,msg){
							var option= '<option onclick="" value="'+ msg.id +'" id="'+ msg.id +'">'+ msg.name +'</option>';
							li.append(option);
						});
					} 
			);
		});

	//增加商店商品增加
	$(".add-goods-addbtn").click(function(){
		  	var li = $(this).parents(".add-goods-ul").children("li");
		  	var length = li.length;
			li.eq(length-1).clone(true).appendTo(".add-goods-ul");
			$(this).parents(".add-goods-ul").children("li").each(function(i){
					$(this).attr("id","add_goods_li_"+(i+1));
				});
		});

	//增加商店商品删除
	$(".add-goods-delbtn").click(function(){
		  	var li = $(this).parents(".add-goods-ul").children("li");
		  	var length = li.length;
		  	if(length == 1){
			  	return false;
		  	}
			$(this).parent().remove();
			$(this).parents(".add-goods-ul").children("li").each(function(i){
					$(this).attr("id","add_goods_li_"+(i+1));
				});
		});

	//获取增加商店的商品列表
	$(".add_shop_selected").change(function(){
			var shopid= 60000;
			var li = $(this).siblings(".add_goods_selected");
			li.empty();
			$.getJSON(
					'activity_manage.php?act=goodslist',
					{shopid:shopid},
					function(callback){
						$.each(callback,function(i,msg){
							var option= '<option onclick="" value="'+ msg.id +'" id="'+ msg.id +'">'+ msg.name +'</option>';
							li.append(option);
						});
					} 
			);
		});
  	
  	//礼包折叠
	$("tr.parent").click(function(){   // 获取所谓的父行
		$(this).toggleClass("title-selected")   // 添加/删除高亮
					.siblings('.child_'+this.id).toggle();  // 隐藏/显示所谓的子行
	}).click();

	//增加礼包
	$(".add-gift-package-btn").click(function(){
		var table = $(".gift-package-table").eq(0).clone(true);
		table.appendTo(".gift-package-div"); 

		$(".gift-package-table").each(function(i){
			 $(this).find(".gift-package-id").html(i+1);
			 $(this).find(".gift_item_ul").attr('id','gift_item_ul_'+(i+1));
			 var id = i+1;
			 $(this).find(".giftItem-name").each(function(i){
					$(this).attr('name','gifts['+id+'][item]['+i+'][name]');
			 });
			 $(this).find(".giftItem-num").each(function(i){
					$(this).attr('name','gifts['+id+'][item]['+i+'][num]');
			 });
			 $(this).find(".giftItem-property-bang").each(function(i){
				$(this).attr('name','gifts['+id+'][item]['+i+'][property]').attr('checked','checked');
			 });
			 $(this).find(".giftItem-property-unbang").each(function(i){
					$(this).attr('name','gifts['+id+'][item]['+i+'][property]');
				 });
			 
			 $(this).find(".charge-num").attr('name','gifts['+id+'][charge_num]');
			 $(this).find(".consume-num").attr('name','gifts['+id+'][consume_num]');
			 $(this).find(".charge-one-num").attr('name','gifts['+id+'][charge_one_num]');
			 $(this).find(".package-type").attr('name','gifts['+id+'][package_type]');
			 $(this).find(".online-time").attr('name','gifts['+id+'][online_time]');
			 $(this).find(".vip-level").attr('name','gifts['+id+'][vip_level]');
			 $(this).find(".continues-login").attr('name','gifts['+id+'][continues_login]');
			 $(this).find(".continues-logoff").attr('name','gifts['+id+'][continues_logoff]');
			 $(this).find(".receive-rose").attr('name','gifts['+id+'][receive_rose]');
			 $(this).find(".rank-type").attr('name','gifts['+id+'][rank_type]');
			 $(this).find(".rank-index-min").attr('name','gifts['+id+'][rank_index_min]');
			 $(this).find(".rank-index-max").attr('name','gifts['+id+'][rank_index_max]');
			 $(this).find(".system-function").attr('name','gifts['+id+'][system_function]');
			 $(this).find(".system-times").attr('name','gifts['+id+'][system_times]');
			 $(this).find(".profession-limit-zhanshi").attr('name','gifts['+id+'][profession_limit_zhanshi]');
			 $(this).find(".profession-limit-fashi").attr('name','gifts['+id+'][profession_limit_fashi]');
			 $(this).find(".profession-limit-gongshou").attr('name','gifts['+id+'][profession_limit_gongshou]');
			 $(this).find(".level-min-limit").attr('name','gifts['+id+'][level_min_limit]');
			 $(this).find(".level-max-limit").attr('name','gifts['+id+'][level_max_limit]');
			 $(this).find(".bang-level").attr('name','gifts['+id+'][bang_level]');
			 $(this).find(".bang-bloom").attr('name','gifts['+id+'][bang_bloom]');
			 $(this).find(".friend-times").attr('name','gifts['+id+'][friend_times]');
			 $(this).find(".sex-limit").attr('name','gifts['+id+'][sex_limit]');
		});
	});   

	//删除礼包
   	$(".close-package").click(function(){
   	   	var t = $(".gift-package-div").children("table");			
   	   	if(t.length == 1)
   	   	{
   	   	   	return false;
   	   	}
		$(this).parents(".gift-package-table").remove();
		$(".gift-package-table").each(function(i){
			 $(this).find(".gift-package-id").html(i+1);
			 $(this).find(".gift_item_ul").attr('id','gift_item_ul_'+(i+1));
			 var id = i+1;
			 $(this).find(".giftItem-name").each(function(i){
				 $(this).attr('name','gifts['+id+'][item]['+i+'][name]');
			 });
			 $(this).find(".giftItem-num").each(function(i){
				 $(this).attr('name','gifts['+id+'][item]['+i+'][num]');
			 });
			 $(this).find(".giftItem-property-bang").each(function(i){
				 $(this).attr('name','gifts['+id+'][item]['+i+'][property]').attr('checked','checked');
			 });
			 $(this).find(".giftItem-property-unbang").each(function(i){
				 $(this).attr('name','gifts['+id+'][item]['+i+'][property]');
			 });
			 $(this).find(".sex-limit").each(function(i){
				 $(this).attr('name','gifts['+id+'][sex-limit]');
			});
		});
   	 });

	//增加礼包物品
	$(".add-giftitem-btn").click(function(){
		var id = $(this).parents(".gift-package-table").find(".gift-package-id").text();
		$(".gift_item_li").eq(0).clone(true).appendTo("#gift_item_ul_"+id);
		$(this).parents(".gift-package-table").find(".giftItem-name").each(function(i){
				$(this).attr('name','gifts['+id+'][item]['+i+'][name]');
		});
		$(this).parents(".gift-package-table").find(".giftItem-num").each(function(i){
				$(this).attr('name','gifts['+id+'][item]['+i+'][num]');
		});
		$(this).parents(".gift-package-table").find(".giftItem-property-bang").each(function(i){
			$(this).attr('name','gifts['+id+'][item]['+i+'][property]').attr('checked','checked');
		});
		$(this).parents(".gift-package-table").find(".giftItem-property-unbang").each(function(i){
			$(this).attr('name','gifts['+id+'][item]['+i+'][property]');
		});
	});

	//删除礼包物品
	$(".del-giftitem-btn").click(function(){
		var id = $(this).parents(".gift-package-table").find(".gift-package-id").text();
		var li = $("#gift_item_ul_"+id).children("li");
		if(li.length == 1)
		{
			return false;
		}
		$(this).parents(".gift_item_li").remove();
	});

	//提交表单
	$('#submit').click(function(){
		var options = { 
		    url:   'activity_manage.php?act=save', 
		    beforeSubmit: validate,
		    resetForm:false,
		    success:    function(callback) {
							    	if(callback == 1) 
							    	{
								        alert('添加活动成功!'); 
								        window.location.href="activity_list.php";
							    	}
							    	else
							    	{
								    	alert('添加失败！');
							    	}
		    } 
		}; 
		 
		$('#actForm').ajaxForm(options);
	});
	
 })
  
var editor;
KindEditor.ready(function(K) {
        editor = K.create('textarea[name="actContent"]',{filterMode : true,height : '250px',width:'700px'}); 
        editor.sync();
});

//提交数据检查
function validate(formData, jqForm, options)
{ 
    for (var i=0; i < 6; i++) 
    { 
        if (!formData[i].value) 
        {
            if(i == 1)	//服务器
            {
	            alert('请选择服务器!'); 
	            return false; 
            } 
            else if(i == 2)
            {
	            alert('请输入活动名称!'); 
	            return false; 
            }
            else if(i == 3)
            {
	            alert('请输入活动开始时间!'); 
	            return false; 
            }
            else if(i == 4)
            {
	            alert('请输入活动领奖时间!'); 
	            return false; 
            }
            else if(i == 5)
            {
	            alert('请输入活动到期时间!'); 
	            return false; 
            }
        }
    }

    var starttime = formData[3].value;
    var awardtime = formData[4].value;
    var endtime = formData[5].value;

    if(Date.parse(starttime.replace("-","/"))>Date.parse(awardtime.replace("-","/"))){
        alert('活动开始时间不能晚于活动领奖时间!'); 
        return false; 
    }
    
    if(Date.parse(awardtime.replace("-","/"))>Date.parse(endtime.replace("-","/"))){
        alert('活动领奖时间不能晚于活动结束时间!'); 
        return false; 
    }

    if(Date.parse(starttime.replace("-","/"))>Date.parse(endtime.replace("-","/"))){
        alert('活动开始时间不能晚于活动结束时间!'); 
        return false; 
    }
    

    editor.sync();
    var actcontent =  editor.html();
    if(!actcontent || actcontent.length > 120)
    {
        alert('请输入活动内容，且最多输入120个汉字!'); 
        return false; 
    }
    return true;
}

</script>

</body>
</html>
